package com.ilink.teacherservice.mapper.study.tree;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ilink.teacherservice.entity.PO.study.tree.TagEntity;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StudyTreeTagMapper extends BaseMapper<TagEntity> {
    @Select("SELECT tag_name FROM study_tree_tag")
    List<String> getAllTags();

    @Select("SELECT stt.tag_id, stt.tag_name FROM study_tree_tag stt " +
            "JOIN study_tree_json_tag stjt ON stt.tag_id = stjt.tag_id " +
            "GROUP BY stt.tag_id, stt.tag_name " +
            "ORDER BY COUNT(stjt.tag_id) DESC " +
            "LIMIT 8")
    List<TagEntity> getCommonTags();
}
